﻿@using SmartCode
@using SmartCode.Db
@model BuildContext
@{
    var project = Model.Project;
    var dbSource = Model.GetDataSource<DbSource>();
    var buildTask = Model.Build;
    buildTask.Parameters.TryGetValue("LogicalDelete", out var logicalDeleteKey);
    var table = Model.GetCurrentTable();
    var pkCol = table.PKColumn;
}

@if (logicalDeleteKey != null)
{
    <update id="deleteById">
        <bind name="id" value="_parameter"/>
        update @table.Name
        set @logicalDeleteKey =1
        where @pkCol.Name=#{id}
    </update>
}
else
{
    <delete id="deleteById">
        <bind name="id" value="_parameter"/>
        delete from @table.Name
        where @pkCol.Name=#{id}
    </delete>
}